package com.xlisteven.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xlisteven.mapper.FruitsMapper;
import com.xlisteven.service.IFruitsService;
import com.xlisteven.entity.Fruits;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FruitsServiceImpl extends ServiceImpl<FruitsMapper, Fruits> implements IFruitsService {
    @Resource
    private FruitsMapper fruitsMapper;

    @Override
    public List<Fruits> getFruitsList(Long userId) {
        LambdaQueryWrapper<Fruits> wrapper = new QueryWrapper<Fruits>().lambda();
        wrapper.eq(Fruits::getUserId, userId);
        return fruitsMapper.selectList(wrapper);
    }

    @Override
    public void insert(List<Fruits> fruitsList) {
        this.saveBatch(fruitsList);
    }
}
